package org.linlinjava.litemall.admin.dto;


import org.linlinjava.litemall.db.domain.LitemallCompanyCharge;

import java.math.BigDecimal;

public class ChargeDto {
    LitemallCompanyCharge charge;
    CdkeyDto[] cdkeys;

    public LitemallCompanyCharge getCharge() {
        return charge;
    }

    public void setCharge(LitemallCompanyCharge charge) {
        this.charge = charge;
    }

    public CdkeyDto[] getCdkeys() {
        return cdkeys;
    }

    public void setCdkeys(CdkeyDto[] cdkeys) {
        this.cdkeys = cdkeys;
    }
    //面值是否匹配
    public boolean isMatchValue(){
        BigDecimal chargeValue = this.charge.getChargeMoney();
        BigDecimal cdkeyValue = BigDecimal.ZERO;
        for (CdkeyDto cdkey: this.cdkeys
             ) {
            cdkeyValue = cdkeyValue.add(cdkey.totalValue());
        }
        return cdkeyValue.equals(chargeValue);
    }
}
